package cn.wb.base.util;

import lombok.Data;

@Data
public class AjaxResult {

    private Boolean success;

    private String msg;

    private Object resultObj;

    public static AjaxResult me(){
        return new AjaxResult();
    }

    public AjaxResult fail(String msg){
        return me().setSuccess(false).setMsg(msg);
    }

    public AjaxResult fail(){
        return me().setSuccess(false).setMsg("操作失败！");
    }

    public AjaxResult success(){
        return me().setSuccess(true).setMsg("操作成功！");
    }
    public AjaxResult success(Object resultObj){
        return me().setSuccess(true).setMsg("操作成功！").setResultObj(resultObj);
    }

    public AjaxResult setSuccess(Boolean success){
        this.success = success;
        return this;
    }

    public AjaxResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public AjaxResult setResultObj(Object resultObj) {
        this.resultObj = resultObj;
        return this;
    }
}
